This article is in the study summary, welcome reprint but please indicate the origin: http://blog.csdn.net/pistolove/article/details/41346969
After reading this article, you may learn the following knowledge:
(1) javaswing in the mouse to monitor common listeners, including MouseListener, Mousewheellistener, Mousemotionlistener.
(2) different to the mouse listener to the effect of what each is, the mouse to do what operation before calling.
(3) The difference between MouseListener and
, 15, 550, 126);
Add the button and text box to the F.add (TF1);
F.add (TF2);
F.add (TF3);
F.add (B1);
F.add (B2);
F.add (B3);
F.add (TF4);
F.add (TF5);
F.add (TF6);
F.add (B4);
F.add (B5);
F.add (B6);
Invoke Event Listener function MyEvent ();
F.setvisible (TRUE); private void MyEvent () {//click on the upper right corner x exit F.addwindowlistener (New Windowadapter () {public void windowclosing (WindowEvent e)
{system.exit (0);}
}); Click the response event B1.addmouselistener for the first b
Package com.yc.utils;Import java.sql.SQLException;public class Shellutil {Private Boolean flag=false;private int xx; The x-axis of the mouse position when you click the interfaceprivate int yy; The y-axis of the mouse position when you click the interfaceMain Panel off Button listener eventpublic void Opbuttonclose (final Label label,final Shell shell,final String uaccount) {Label.addmousetracklistener (New Mousetrackadapter () {@Overridepublic void Mouseexit (MouseEvent e) {Label.setimage (Swtr
Btnnewbutton.addmouselistener (New Mouseadapter () {public void mouseclicked (MouseEvent e) {//Error dialog boxJoptionpane.showmessagedialog (NULL,"This is an error dialog box,""Error_message",Joptionpane.error_message);}});Button.addmouselistener (New Mouseadapter () {public void mouseclicked (MouseEvent e) {//Internal Information dialog boxJoptionpane.showmessagedialog (NULL,"This is an internal Informati
I used the Parent and Child Window to pass the value and searched the internet for a bunch of nonsense. I felt very uncomfortable. I studied it for a long time. It turned out to be very simple. The thread is also used in this example. You don't need to be more clear. Let's just move on to the code. note how to pass the value in the ///// Dialog Box package des; import java. AWT. color;
Import java. AWT. Dialog;
Import java. AWT. Font;
Import java. AWT. frame;
Import java. AWT. graphicsconfigurat
mouseadapter this abstract class2 must be implemented (one of the methods, which is implemented here) mousepressed (MouseEvent e) This methodClass Monitor extends mouseadapter{Mouselistener-->mouseadapter-->monitor (): If you implement the interface directly, you need to implement the interface method, but still mouseadapter
This article mainly shares the relevant information about a small program that counts the amount of code and has some reference value. if you are interested, you can refer to it and run it directly: Select the src folder, just click "count the number of rows ".
Import java. awt. eventQueue; import java. awt. font; import java. awt. event. mouseAdapter; import java. awt. event. mouseEvent; import java. io. bufferedReader; import java. io. file; import
heightFillRect:G. fillRect (44,44, 44,44); // draw a solid rectangle, position, width, and height.DrawOval:G. drawOval (,); // draw a hollow oval (inner tangent oval), position, width and heightDrawRect:G. drawRect (,); // draw a hollow rectangle, position, width and height.MouseAdapter:F. addMouseListener (new listener class); // bind a mouse listener to trigger the listener. The mousePressed (MouseEvent e) method is called by default.Bind a mouse listener:1. The Listener class must inherit th
1Paint ()
1 package hello; 2 Import Java. AWT. *; 3 Public class helloworld 4 {5 public static void main (string [] ARGs) throws exception 6 {7 new F (). launchframe (); 8} 9} 10 11 Class F extends frame12 {13 public void launchframe () 14 {15 setbounds (200,300,600,700); 16 setvisible (true ); 17} 18 public void paint (Graphics g) // frame is automatically called 19 {20 color C = G. getcolor (); // obtain the original color of 21 GB. setcolor (color. green); // 22g. filloval (50, 50, 30, 30); 2
First remove the Border setundecorated (true);//Add the label as the Close button JLabel Subcloselabel = new JLabel ("");//The position of the button subcloselabel.setbounds (860, 0 , 40, 30);//Click Listen Subcloselabel.addmouselistener (New Mouseadapter () {@Overridepublic void mouseclicked (MouseEvent e) { JLabel closelabel= (JLabel) E.getsource ();//Get top-Level form Subwindow mysubwindowbuider= (subwindow) Closelabel.gettoplevelancestor (); Mysu
The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion;
products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the
content of the page makes you feel confusing, please write us an email, we will handle the problem
within 5 days after receiving your email.
If you find any instances of plagiarism from the community, please send an email to:
info-contact@alibabacloud.com
and provide relevant evidence. A staff member will contact you within 5 working days.